<?php


namespace app\modules\Merchant\models;


use goodsskupriceModel;
use Illuminate\Database\Eloquent\SoftDeletes;

class dianpuwalletapplylogModel extends \Illuminate\Database\Eloquent\Model
{
    protected $table = 'dianpu_wallet_apply_log';
    protected $primaryKey = 'id';
    protected $appends = ['event_name', 'oper_type_text'];

    protected static $ALLEVENT = [
        'apply'=>'申请提现',
        'denied'=>'拒绝提现',
        'agree'=>'同意提现',
        'finished'=>'已打款',
    ];

    protected static array $AllOperTypes = [
        'admin'=>'管理员',
        'system'=>'系统',
        'user'=>'用户',
    ];

    protected function serializeDate($date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public static function getAllEvent()
    {
        return self::$ALLEVENT;
    }

    public function getEventNameAttribute($value)
    {
        return self::$ALLEVENT[$this->attributes['event']]??'未知';
    }

    public function getOperTypeTextAttribute($value)
    {
        return self::$AllOperTypes[$this->attributes['oper_type']]??'未知';
    }

    public function apply()
    {
        return $this->belongsTo(dianpuwalletapplyModel::class, 'apply_id', 'id');
    }
}